package cn.good.user.service;

import cn.good.service.SmsCodeService;
import com.alibaba.dubbo.config.annotation.Service;
//import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Set;
@Component
@Service(interfaceClass = SmsCodeService.class)
public class SmsCodeServiceImpl implements SmsCodeService {

//   @Resource
//    private CCPRestSmsSDK ccpRestSDK;

    /**
     * 设置短信，发送
     * @param phone
     * @param code
     * @return
     */
    @Override
    public Boolean smsCodeSend(String phone, String code) {
        HashMap<String, Object> result = null;
//        result = ccpRestSDK.sendTemplateSMS(phone,"1",new String[] { code, "2" });
        System.out.println("SDKTestVoiceVerify result=" + result);
        if("000000".equals(result.get("statusCode"))){
            //正常返回输出data包体信息（map）
            HashMap<String,Object> data = (HashMap<String, Object>) result.get("data");
            Set<String> keySet = data.keySet();
            for(String key:keySet){
                Object object = data.get(key);
                System.out.println(key +" = "+object);
            }
        }else{
            //异常返回输出错误码和错误信息
            System.out.println("错误码=" + result.get("statusCode") +" 错误信息= "+result.get("statusMsg"));
        }
        return null;
    }
}
